package beautiful.butterfly.server.application;


import beautiful.butterfly.server.httpserver.handler.HttpServer;
import beautiful.butterfly.server.httpserver.handler.IHttpServer;
import beautiful.butterfly.server.httpserver.mvc.handler.DefaultExceptionHandler;
import beautiful.butterfly.server.httpserver.mvc.handler.ExceptionHandler;
import lombok.extern.slf4j.Slf4j;


/**
 * 整个系统需要各个服务器组件分开
 */
@Slf4j
public class Application {

    public static boolean developMode = false;
    private String path;
    private IHttpServer httpServer = new HttpServer();

    private Environment environment = new Environment();
    private ExceptionHandler exceptionHandler = new DefaultExceptionHandler();

    public Application(String path) throws Exception {
        this.path = path;
    }

    public Environment environment() {
        return environment;
    }

    public String getPath() {
        return path;
    }


    public ExceptionHandler getExceptionHandler() {
        return exceptionHandler;
    }


    public Application start() {
        try {

            httpServer.start(Application.this);
            httpServer.join();

        } catch (Exception e) {
            e.printStackTrace();
        }
        return this;
    }


}
